<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWechatMenuTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('wechat_menu', [
            'comment' => '微信公众号菜单', 
            'engine' => 'InnoDB', 
            'collation' => 'utf8mb4_general_ci'
        ]);
        $table->addColumn('name', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '菜单名称'])
            ->addColumn('rules', 'text', ['null' => true, 'default' => null, 'comment' => '菜单规则'])
            ->addColumn('status', 'integer', ['limit'  =>  1, 'default' => 0, 'comment' => '状态:0=未发布,1=已发布'])
            ->addColumn('publish_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '发布时间'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '删除时间'])
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('wechat_menu');
        $table->drop();
    }
}
